CREATE TABLE `SRTrade`.`MsgSRRiskExecution` (
`fillNumber` BIGINT NOT NULL DEFAULT 0 COMMENT 'SpiderRock execution number (globally unique over trailing 10 days)',
`sysRealm` ENUM('None','SysTest','NMS','CME','FR2','LD4','DR') NOT NULL DEFAULT 'None',
`sysEnvironment` ENUM('None','Neptune','Pluto','V7_Stable','V7_Latest','Saturn','Venus','Mars','SysTest','V7_Current') NOT NULL DEFAULT 'None' COMMENT 'original (source) sys environment [Stable, Current, etc]',
`runStatus` ENUM('None','Prod','Beta','UAT','SysTest') NOT NULL DEFAULT 'None' COMMENT 'original (source) run status [Prod,Beta]',
`version` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'record version number;starts at zero and goes up every time an execution record is re-published (eg, bust, +1m marks, +10m marks, etc)',
`execStatus` ENUM('None','Fill','Bust','Correct','Reject','SysRej') NOT NULL DEFAULT 'None' COMMENT 'SpiderRock execution status (Fill,Bust,Correct,Reject,SysRej)',
`execShape` ENUM('None','Single','MLegTop','MLegLeg','SpreadTop','SpreadLeg','SingleLeg') NOT NULL DEFAULT 'None',
`packageId` BIGINT NOT NULL DEFAULT 0 COMMENT 'SR package Id',
`parentNumber` CHAR(19) NOT NULL DEFAULT '0000-0000-0000-0000' COMMENT 'SR parent number',
`parentVersion` SMALLINT NOT NULL DEFAULT 0 COMMENT 'SPDR order instance number (1 = original order; 2 = 1st cancel/replace, etc)',
`baseParentNumber` CHAR(19) NOT NULL DEFAULT '0000-0000-0000-0000' COMMENT 'SPDR order number (initial number in cancel/replace sequence) (also, source parent for dynamically generated orders;eg auto-hedges)',
`clOrdId` CHAR(19) NOT NULL DEFAULT '0000-0000-0000-0000' COMMENT 'SR child order clOrdID resulting in fill',
`riskGroupId` CHAR(19) NOT NULL DEFAULT '0000-0000-0000-0000' COMMENT 'riskGroupId (parent order group ID) for this execution report',
`parentShape` ENUM('None','Single','Cross','MLeg','MLegCross') NOT NULL DEFAULT 'None' COMMENT 'shape of originating parent order',
`secKey_at` ENUM('None','EQT','IDX','BND','CUR','COM','FUT','SYN','WAR','FLX','MUT','SPD','MM','MF','COIN','TOKEN','ANY') NOT NULL DEFAULT 'None' COMMENT 'execution security key',
`secKey_ts` ENUM('None','SR','NMS','CME','ICE','CFE','CBOT','NYMEX','COMEX','RUT','CIDX','ARCA','NYSE','OTC','NSDQ','MFQS','MIAX','DJI','CUSIP','ISIN','BXE','EUX','ANY','CXE','DXE','NXAM','NXBR','NXLS','NXML','NXOS','NXP','EUREX','CEDX','ICEFE') NOT NULL DEFAULT 'None' COMMENT 'execution security key',
`secKey_tk` VARCHAR(12) NOT NULL DEFAULT '' COMMENT 'execution security key',
`secKey_yr` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'execution security key',
`secKey_mn` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'execution security key',
`secKey_dy` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'execution security key',
`secKey_xx` DOUBLE NOT NULL DEFAULT 0 COMMENT 'execution security key',
`secKey_cp` ENUM('Call','Put','Pair') NOT NULL DEFAULT 'Call' COMMENT 'execution security key',
`secType` ENUM('None','Stock','Future','Option','MLeg') NOT NULL DEFAULT 'None' COMMENT 'execution security type [Stock, Future, Option]',
`ticker_at` ENUM('None','EQT','IDX','BND','CUR','COM','FUT','SYN','WAR','FLX','MUT','SPD','MM','MF','COIN','TOKEN','ANY') NOT NULL DEFAULT 'None' COMMENT 'base stock key (used for symbol risk aggregation)',
`ticker_ts` ENUM('None','SR','NMS','CME','ICE','CFE','CBOT','NYMEX','COMEX','RUT','CIDX','ARCA','NYSE','OTC','NSDQ','MFQS','MIAX','DJI','CUSIP','ISIN','BXE','EUX','ANY','CXE','DXE','NXAM','NXBR','NXLS','NXML','NXOS','NXP','EUREX','CEDX','ICEFE') NOT NULL DEFAULT 'None' COMMENT 'base stock key (used for symbol risk aggregation)',
`ticker_tk` VARCHAR(12) NOT NULL DEFAULT '' COMMENT 'base stock key (used for symbol risk aggregation)',
`accnt` VARCHAR(16) NOT NULL DEFAULT '' COMMENT 'SpiderRock trading accnt [broker pkey]',
`clientFirm` VARCHAR(16) NOT NULL DEFAULT '' COMMENT 'SR client firm',
`spdrSource` ENUM('None','SpdrTicket','SpdrSingle','SRSE','FIX','HedgeTool','TradeHedge','OpenHedge','AutoHedge','Orphan','RiskManager','OrderManager','ManagedOrder','RFQRespSrvr','Legger','SRSEDrop','FixDrop','TicketDrop','SysTest','RFRResponse','AllocOmni','AllocClient','CertGateway','MLegResponse','LeggerX','DropManager','AutoHedgeSrvr','AuctionStrategySrvr','AllocBlockFace','AllocBlockCust','IceChatGateway','EXS2SRC','MLinkResponse','AutoResponderVD','AutoResponderRC','AutoResponderSN','AutoResponderBX','MLink') NOT NULL DEFAULT 'None' COMMENT 'SpiderRock parent order source code [broker pkey]',
`groupingCode` CHAR(19) NOT NULL DEFAULT '0000-0000-0000-0000' COMMENT 'SpiderRock parent broker number [broker pkey]',
`engineName` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'SpiderRock execution engine that handled the parent order',
`execRole` ENUM('None','DirectAccnt','AwayGiveup','RiskDrop','AwayDrop','PullDrop') NOT NULL DEFAULT 'None' COMMENT 'SpiderRock relationship to this execution record',
`childOrderHandling` VARCHAR(24) NOT NULL DEFAULT '' COMMENT 'child order handling string from the algo that generated the child order responsible for this fill',
`childAlgoHandler` ENUM('None','ActiveTaker','ActiveMaker','Auction','Responder','Matrix','Cross','Face','Extern','MLegHandler','AutoHedge','Sprayer','Legger','Restart','Orphan','UDefSpread','RFQRequest','MLegResponder','LeggerX','ExchPing','BrkrReview','AuctionResponder','TakeSweep','TestChild') NOT NULL DEFAULT 'None' COMMENT 'algo handler for this child order',
`childSSaleFlag` ENUM('None','Long','Short','Exempt','Auto','Open','Close','Cover','NA') NOT NULL DEFAULT 'None' COMMENT 'short sale flag',
`userName` VARCHAR(24) NOT NULL DEFAULT '' COMMENT 'user name associated with the parent order',
`orderSide` ENUM('None','Buy','Sell') NOT NULL DEFAULT 'None' COMMENT 'order side',
`spdrOrderStatus` ENUM('PendNew','New','PendClose','Closed','Rejected','SendReject') NOT NULL DEFAULT 'PendNew',
`spdrCloseReason` ENUM('None','Cancelled','Filled','Replaced','Expired','Limit','System','LegReject','DoneForDay','IOCExpire','UserCxl','NoProgress','TooManyRej','ReplReject','AlgoClose','Restart','InvldParentLimit','FilledRepl','ForceClose','DmaReject','DmaExpire','DmaBrkrCxl','ReviewReject','MarketState','AlgoReject','ReviewTimeout','ChildReject','ChildCancel','ReviewClose','UPrcRange','LegBrkrClosed','ExchRisk','CrossFailed') NOT NULL DEFAULT 'None',
`cumFillQuantity` INT NOT NULL DEFAULT 0 COMMENT 'cumulative fills (this parent number only)',
`avgFillPrice` DOUBLE NOT NULL DEFAULT 0,
`cumLegFillQuantity` INT NOT NULL DEFAULT 0 COMMENT 'cumulative fills (spread only)',
`avgLegFillPrice` DOUBLE NOT NULL DEFAULT 0,
`leavesQty` INT NOT NULL DEFAULT 0,
`priceType` ENUM('None','Explicit','Offset','Zero') NOT NULL DEFAULT 'None',
`firmType` ENUM('None','Customer','Firm','MarketMaker','ProCustomer','BrokerDealer','AwayMM','FirmJBO','BrkrDlrCust') NOT NULL DEFAULT 'None' COMMENT 'child order firm type [Customer, ProCust, Firm, MM, etc]',
`priAggGroup` VARCHAR(16) NOT NULL DEFAULT '' COMMENT 'primary aggregation group',
`secAggGroup` VARCHAR(16) NOT NULL DEFAULT '' COMMENT 'secondary aggregation group',
`fillTransactDttm` DATETIME(6) NOT NULL DEFAULT '1900-01-01 00:00:00.000000' COMMENT 'transaction date/time as reported by exchange or down stream broker',
`fillDttm` DATETIME(6) NOT NULL DEFAULT '1900-01-01 00:00:00.000000' COMMENT 'Date/time of fill arrival (SRDateTime)',
`fillExch` VARCHAR(12) NOT NULL DEFAULT '' COMMENT 'ExDest code from child order execution report',
`fillExecId` TINYTEXT NOT NULL DEFAULT '' COMMENT 'street side execution Id',
`fillExecRefId` TINYTEXT NOT NULL DEFAULT '' COMMENT 'street side execution ref Id (only used when busting an execution)',
`fillLegRefId` BIGINT NOT NULL DEFAULT 0 COMMENT 'legRefId for multileg fills',
`fillLegRatio` INT NOT NULL DEFAULT 0 COMMENT 'legRatio (if spread order)',
`fillExchFee` FLOAT NOT NULL DEFAULT 0 COMMENT 'SpiderRock estimate of the exchange fee based on liquidity tags (best effort)',
`fillMarket` VARCHAR(8) NOT NULL DEFAULT '' COMMENT 'usually from execReport.lastMkt as reported by child order venue',
`fillPrice` DOUBLE NOT NULL DEFAULT 0 COMMENT 'fill price',
`fillQuantity` INT NOT NULL DEFAULT 0 COMMENT 'fill quantity',
`fillBid` DOUBLE NOT NULL DEFAULT 0 COMMENT 'market bid @ fill arrival',
`fillAsk` DOUBLE NOT NULL DEFAULT 0 COMMENT 'market ask @ fill arrival',
`fillMark` DOUBLE NOT NULL DEFAULT 0 COMMENT 'mid-market (or SR surface price if option) @ fill arrival',
`fillUBid` DOUBLE NOT NULL DEFAULT 0 COMMENT 'underlier market bid @ fill arrival',
`fillUAsk` DOUBLE NOT NULL DEFAULT 0 COMMENT 'underlier market bid @ fill arrival',
`fillVol` FLOAT NOT NULL DEFAULT 0 COMMENT 'fill volatility @ fillLimitRefUPrc',
`fillVe` FLOAT NOT NULL DEFAULT 0 COMMENT 'fill vega',
`fillGa` FLOAT NOT NULL DEFAULT 0 COMMENT 'fill gamma',
`fillDe` FLOAT NOT NULL DEFAULT 0 COMMENT 'fill delta',
`fillTh` FLOAT NOT NULL DEFAULT 0 COMMENT 'fill theta',
`fillBeta` FLOAT NOT NULL DEFAULT 0 COMMENT 'SpiderRock estimate of beta to SPX',
`riskVega` FLOAT NOT NULL DEFAULT 0 COMMENT 'risk vega',
`riskWtVega` FLOAT NOT NULL DEFAULT 0 COMMENT 'risk gamma',
`riskNValue` FLOAT NOT NULL DEFAULT 0 COMMENT 'risk delta',
`riskDelta` FLOAT NOT NULL DEFAULT 0 COMMENT 'risk delta',
`riskDDelta` FLOAT NOT NULL DEFAULT 0 COMMENT 'risk ddelta',
`riskRm1` FLOAT NOT NULL DEFAULT 0 COMMENT 'user defined (from parent order) [used to manage order groups',
`riskRm2` FLOAT NOT NULL DEFAULT 0 COMMENT 'user defined (from parent order) [used to manage order groups]',
`riskRm3` FLOAT NOT NULL DEFAULT 0 COMMENT 'user defined (from parent order) [used to manage order groups]',
`riskRm4` FLOAT NOT NULL DEFAULT 0 COMMENT 'user defined (from parent order) [used to manage order groups]',
`riskRm5` FLOAT NOT NULL DEFAULT 0 COMMENT 'user defined (from parent order) [used to manage order groups]',
`riskRm6` FLOAT NOT NULL DEFAULT 0 COMMENT 'user defined (from parent order) [used to manage order groups]',
`riskRm7` FLOAT NOT NULL DEFAULT 0 COMMENT 'user defined (from parent order) [used to manage order groups]',
`marginUDnVDn` FLOAT NOT NULL DEFAULT 0 COMMENT 'underlier down, vol down',
`marginUDnVUp` FLOAT NOT NULL DEFAULT 0 COMMENT 'underlier down, vol up',
`marginUUpVDn` FLOAT NOT NULL DEFAULT 0 COMMENT 'underlier up, vol down',
`marginUUpVUp` FLOAT NOT NULL DEFAULT 0 COMMENT 'underlier up, vol up',
`riskU50Dn` FLOAT NOT NULL DEFAULT 0 COMMENT 'underlier dn 50% shock slide',
`riskU50Up` FLOAT NOT NULL DEFAULT 0 COMMENT 'underlier up 50% shock slide',
`years` FLOAT NOT NULL DEFAULT 0 COMMENT 'years to expiration',
`underliersPerCn` INT NOT NULL DEFAULT 0 COMMENT 'option delivery underliers per contract',
`underlierType` ENUM('None','Equity','Other','FX') NOT NULL DEFAULT 'None' COMMENT 'type of underlier (affects $greek calculations)',
`tickValue` FLOAT NOT NULL DEFAULT 0 COMMENT '$NLV value of a single tick change in display premium (pointValue = tickValue / tickSize)',
`pointValue` FLOAT NOT NULL DEFAULT 0 COMMENT '$NLV value of a single point change in display premium (pointValue = tickValue / tickSize)',
`pointCurrency` ENUM('None','AUD','BRL','CAD','CHF','CNH','CNY','EUR','GBP','JPY','KRW','MXN','MYR','NOK','NZD','SEK','TRY','USD','USDCents','CZK','ZAR','HUF','USX','GBX') NOT NULL DEFAULT 'None',
`uPrcRatio` FLOAT NOT NULL DEFAULT 0 COMMENT 'UPrcRatio (SymbolRatio) from product definition',
`minTickSize` FLOAT NOT NULL DEFAULT 0 COMMENT 'minimum market price variation (dnTickSize if on a boundary)',
`priceFormat` ENUM('None','N0','N1','N2','N3','N4','N5','N6','N7','F4','F8','Q8','F16','F32','H32','Q32','F64','H64','FullPenny','PartPenny','PartNickle','EQT','V1','V2','V3','V4','V5','V6','V7','V8','V9','V10','V11','V12','V13','V14','V15','A0','A1','A2','A3','A4','A5','A6','A7','E32') NOT NULL DEFAULT 'None' COMMENT 'SpiderRock price display format code',
`uPriceFormat` ENUM('None','N0','N1','N2','N3','N4','N5','N6','N7','F4','F8','Q8','F16','F32','H32','Q32','F64','H64','FullPenny','PartPenny','PartNickle','EQT','V1','V2','V3','V4','V5','V6','V7','V8','V9','V10','V11','V12','V13','V14','V15','A0','A1','A2','A3','A4','A5','A6','A7','E32') NOT NULL DEFAULT 'None' COMMENT 'SpiderRock underlier price display format code',
`timestamp` DATETIME(6) NOT NULL DEFAULT '1900-01-01 00:00:00.000000' COMMENT 'timestamp of this record [not necessarily the timestamp of the fill itself]',
CONSTRAINT nonnegative_parentNumber CHECK(ASCII(parentNumber) < 56),
CONSTRAINT nonnegative_baseParentNumber CHECK(ASCII(baseParentNumber) < 56),
CONSTRAINT nonnegative_clOrdId CHECK(ASCII(clOrdId) < 56),
CONSTRAINT nonnegative_riskGroupId CHECK(ASCII(riskGroupId) < 56),
CONSTRAINT nonnegative_groupingCode CHECK(ASCII(groupingCode) < 56),
PRIMARY KEY USING HASH (`fillNumber`),
KEY `AccntIndex` (`accnt`) USING HASH,
KEY `ClientFirmIndex` (`clientFirm`) USING HASH
) ENGINE=SRSE DEFAULT CHARSET=LATIN1 COMMENT='SpdrRiskExecution records are published every time a SpdrParentExecution record is published';